package com.cy.pj.sys.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cy.pj.common.bo.JsonResult;
import com.cy.pj.sys.pojo.SysMenu;
import com.cy.pj.sys.service.SysMenuService;

//@Controller
//@ResponseBody  //如果类中 !!(所有方法)!! 都需要使用这个注解,可以再类上加这个注解
@RestController //等效于 @Controller+@ResponseBody
@RequestMapping("/menu/")
public class SysMenuController {
	@Autowired
	private SysMenuService sysMenuService;
	
	@RequestMapping("doUpdateObject")
	public JsonResult doUpdateObject(SysMenu sysMenu) {
		sysMenuService.updateObject(sysMenu);
		return new JsonResult("update ok");
	}
	
	@RequestMapping("doSaveObject")
	//多字段还可以使用Map--需要注解,自行百度
	public JsonResult doSaveObject(SysMenu sysMenu) {
		sysMenuService.saveObject(sysMenu);
		return new JsonResult("delete ok");
	}
	
	@RequestMapping("doFindZtreeMenuNodes")
	public JsonResult doFindZtreeMenuNodes() {
		return new JsonResult(sysMenuService.findZtreeMenuNodes());
	}
	
	@RequestMapping("doDeleteObject")
	public JsonResult doDeleteObject(Integer id) {
		sysMenuService.deleteObject(id);
		return new JsonResult("delete ok");
	}
	
	@RequestMapping("doFindObjects")
	//@ResponseBody //类上加了ResponseBody -- 等于所有方法上默认加了这个注解
	public JsonResult doFindObjects() {
		return new JsonResult(sysMenuService.fundObjects());
	}
	
}
